/**
* @describe 数组工具类
* @author 游金宇(KM)
* @date 2023-08-02 20:15:13
*/

/**
 * 根据自定义字段数组排序
 * @param {T[]} array   数组排序
 * @param {string} field  自定义字段
 * @param {number} sort  方向 1从小到大 -1 从大到小
 */
export const arraySortByField = <T extends Object>(array: T[], field: keyof T, sort: number = 1): void => {
    array.sort((a, b) => ((a[field] as unknown as number) - (b[field] as unknown as number)) * sort);
}
